/*
 * Created on 12 juin 08 by Joseph Poidevin (poidevin@gmail.com)
 */
package org.bigcrunch.processing.libcv;

/**
 * Representation of a region in the camera's field of view
 */
public class Region {

  private int x, y;
  private int w, h;
  private int id;
  public float indicator;

  /**
   * Create a region
   *
   * @param x the x coordinate of the botton left corner
   * @param y the y coordinate of the botton left corner
   * @param w the width of the region
   * @param h the height of the region
   */
  public Region(int x, int y, int w, int h) {
    //System.out.println("new Region("+x+","+y+","+w+","+h+")");
    this.x = x;
    this.y = y;
    this.w = w;
    this.h = h;
  }

  /**
   * Get the X coordinate of the bottom left corner
   */
  public int getX() {
    return x;
  }

  /**
   * Get the Y coordinate of the bottom left corner
   */
  public int getY() {
    return y;
  }

  /**
   * Get the width of the region
   * @return the width of the region
   */
  public int getWidth() {
    return w;
  }

  /**
   * Get the height of the region
   * @return the height of the region
   */
  public int getHeight() {
    return h;
  }

  /**
   * Test if point is in the region
   * @param tx test x coordinate
   * @param ty test y coordinate
   */
  public boolean inRegion(int tx, int ty) {
    return (tx >=x && ty >= y && tx <=x+w && ty <= y+h);
  }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }
    
    public String toString(){
        return "Region[id:"+id+"]["+x+","+y+"]["+w+","+h+"]{"+indicator+"}";
    }
}

